package test37;

import java.io.*;
import java.util.HashSet;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2023-05-09
 * Time: 13:28
 */
public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));;
    static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
    public static void main(String[] args) throws IOException {
        String str = null;
        while ((str = br.readLine()) != null) {
            int len = Integer.parseInt(str);
            String[] orders = new String[len];
            for (int i = 0; i < len; i++) {
                orders[i] = br.readLine();
            }
            //6
            // A connect
            // A disconnect
            // B connect
            // C connect
            // B disconnect
            // C disconnect
            int num = 0;
            int seat = 0;
            Set<Character> hs = new HashSet<>();
            for (String s : orders) {
                if (hs.add(s.charAt(0))) {
                    num++;
                    if (num > seat){
                        seat++;
                    }
                } else {
                    num--;
                    hs.remove(s.charAt(0));
                }
            }
            bw.write(seat + "\n");
            bw.flush();
        }
        bw.close();
        br.close();
    }
}
